﻿Ext.namespace("Swfu");
Ext.namespace("Swfu.BackMgr");

Swfu.BackMgr.ScoreStatMgr = Ext.extend(Ext.grid.GridPanel, {
    initComponent: function () {
        var ddlDeptScoreStat = new Ext.form.TreeField({
            id: 'treeDeptScoreStat', name: 'treeDeptScoreStat',
            dataUrl: '/Dept.mvc/JsonTree',
            baseParams: { deptId: 0 },
            listHeight: 250, width: 150,
            listeners: {
                beforeselect: function (node, ddl) {
                    //改变部门后,必须刷新数据列表
                    //loadDaily(node.id, d);
                    return true;
                }
            }
        });
        var sm = new Ext.grid.CheckboxSelectionModel({ singleSelect: true });
        var fm = Ext.form;

        var cm = new Ext.grid.ColumnModel([
        {
            header: "姓名", dataIndex: 'Name'
        }, {
            header: "分数", sortable: true, dataIndex: 'Score'
        }]);
        var reader = new Ext.data.JsonReader({
            autoLoad: true,
            fields: [{
                name: 'Name'
            }, {
                name: 'Score'
            }]
        });

        var ds = new Ext.data.Store({
            scopte: this,
            id: 'ScoreStatDS',
            url: '/Exam.mvc/ScoreStat',
            reader: reader
        });
        ds.on('beforeload', function (thiz, options) {
            Ext.apply(thiz.baseParams, { deptId: Ext.getCmp('treeDeptScoreStat').getValue() });
        });
        Ext.apply(this, {
            id: 'ScoreStatMgr',
            plain: false,
            layout: 'fit',
            border: false,
            cm: cm,
            sm: sm,
            frame: true,
            store: ds,
            loadMask: true,
            tbar: [{
                text: "重新加载数据",
                iconCls: 'icon-redo',
                handler: function () {
                    ds.reload();
                }
            }, '->', {
                xtype: 'tbtext',
                text: '部门:'
            }, ddlDeptScoreStat, '-', {
                text: "查询",
                iconCls: 'icon-search',
                handler: function () {
                    ds.reload();
                }
            }]
        });
        Swfu.BackMgr.ScoreStatMgr.superclass.initComponent.apply(this, arguments);
        ds.load();
    }
});

Ext.reg('ScoreStatMgr', Swfu.BackMgr.ScoreStatMgr);